package com.longchat.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.longchat.domain.permission.Resource;
import com.longchat.domain.permission.Resource.ResourceType;
import com.longchat.domain.permission.Role;

public interface RoleJpaRepository extends CrudRepository<Role, Integer> {

	@Query("select r.resource from Role r join r.user u where u.userName=?1")
	List<Resource> queryPermissionByUserName(String userName);
	
	@Query("select res from Role r join r.user u join r.resource res where u.userName=?1 and res.type=?2")
	List<Resource> queryPermissionMenuByUserName(String userName,ResourceType type);

}
